package com.shujia.day11;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

class DateUtil {

    public static int dateDiff(Date date1, Date date2) {
        double VALUE = 1000 * 60 * 60 * 24.0;
        double res = (date1.getTime() - date2.getTime()) / VALUE;

        return (int) Math.ceil(Math.abs(res));
    }

    public static int dateDiff(String str1, String str2) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date1 = dateFormat.parse(str1);
        Date date2 = dateFormat.parse(str2);
        return dateDiff(date1, date2);
    }
}


public class HDateUtilDemo {
    public static void main(String[] args) throws ParseException {
//        Date date = new Date();
//        System.out.println(date.getTime());

        int i = DateUtil.dateDiff("2023-08-27 09:30:30", "2023-08-28 08:30:30");
        System.out.println(i);
    }
}
